{include file=header.html}
<style type="text/css">
<!--
.error{
	color: red;
}
-->
</style>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script type="text/javascript">
	//注册表单验证
	$(function() {
		regionInit('regions');
		$('#consumer_form').validate({
			errorPlacement : function(error, element) {
				var error_td = element.parent('td');
				error_td.find('.field_notice').hide();
				error_td.append(error);
			},
			success : function(label) {
				label.addClass('validate_right').text('OK!');
			},
			onkeyup : false,
			rules : {
				user_name : {
					required : true,
					byteRange : [ 3, 25, '{$charset}' ],
					remote : {
						url : 'index.php?app=member&act=check_user&ajax=1',
						type : 'get',
						data : {
							user_name : function() {
								return $('#user_name').val();
							},
							uid : '{$user.user_id}'
						},
						beforeSend : function() {
							var _checking = $('#checking_user');
							_checking.prev('.field_notice').hide();
							_checking.next('label').hide();
							$(_checking).show();
						},
						complete : function() {
							$('#checking_user').hide();
						}
					}
				},
				password : {
					minlength : 6
				},
				confirm_password : {
					equalTo : '#password'
				},
				consumer_name : {
					required : true
				},
				region_name : {
					required : true
				},
				email : {
					required : true,
					email : true,
					remote : {
						url : 'index.php?app=member&act=check_email&ajax=1',
						type : 'get',
						data : {
							email : function() {
								return $('#email').val();
							},
							id : '{$user.user_id}'
						}
					}
				},
				address : {
					required : true,
					maxlength: 100
				},
				phone_tel : {
					required : check_phone
				},
				phone_mob : {
					required : check_phone
				}
			},
			messages : {
				user_name : {
					required : '{$lang.user_name_required}',
					byteRange : '{$lang.user_name_limit}',
					remote : '{$lang.user_already_taken}'
				},
				password : {
					minlength : '{$lang.password_length_limit}'
				},
				confirm_password : {
					equalTo : '{$lang.password_inconsistent}'
				},
				consumer_name : {
					required : '{$lang.consumer_name_required}'
				},
				region_name : {
					required : '{$lang.region_required}'
				},
				email : {
					required : '{$lang.email_required}',
					email : '{$lang.email_invalid}',
					remote : '{$lang.email_already_taken}'
				},
				address : {
					required : '{$lang.address_required}',
					maxlength: '{$lang.address_length_error}'
				},
				phone_tel : {
					required : '{$lang.phone_tel_required}'
				},
				phone_mob : {
					required : '{$lang.phone_mob_required}'
				}
			}
		});
		
		//如果选中则可见,反之则不可见
		if($('#entity_store').is(':checked')){
			$('#entity_store_num').removeAttr('disabled');
		}else{
			$('#entity_store_num').attr('disabled','disabled');
		}
		
		$('#entity_store').click(function(){
			if($(this).is(':checked')){
				$('#entity_store_num').removeAttr('disabled');
			}else{
				$('#entity_store_num').attr('disabled','disabled');
			}
		});
		
		if($('#net_store').is(':checked')){
			$('#net_store_num').removeAttr('disabled');
		}else{
			$('#net_store_num').attr('disabled','disabled');
		}
		
		$('#net_store').click(function(){
			if($(this).is(':checked')){
				$('#net_store_num').removeAttr('disabled');
			}else{
				$('#net_store_num').attr('disabled','disabled');
			}
		});
		
		//默认为国家为'中国',不是则区域选择不可见
		var reg=$('#region_hidden').clone(true);
		$('#country').keyup(function(){
			if($(this).val()!='中国'){
				$(this).parent().parent().next().remove('#region_hidden');
			}else{
				$(this).parent().parent().after(reg);
			}
		});
		$('#country').blur(function(){
			if($(this).val()!='中国'){
				$(this).parent().parent().next().remove('#region_hidden');
			}else{
				if(!$(this).parent().parent().next().is('#region_hidden')){
					$(this).parent().parent().after(reg);
				}
			}
		});
		
		//禁止右键复制
		$('#country').bind('contextmenu', function() {
		      return false;
		});
	});
	 function check_phone(){
         return ($('#phone_tel').val() == '' && $('#phone_mob').val() == '');
     }
</script>
    <script type="text/javascript">
function chang_tab(obj)
{
	$(".introduce_ti p").each(function(){
		$(this).attr('class','');
	});
	$("#zc"+obj).attr('class','in_tis');
}
</script>
<style type="text/css">
input {
	vertical-align: -5px;_vertical-align: -1px;margin-right: 5px
}

.tab-frame {
	width: 750px;
}
</style>
	<div class="sub-body">
		<div>
			<form name="" id="consumer_form" method="post" action="" class="tab-frame">
				<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
					<tr>
						<td width="15%" align="right">用户名:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="user_name" name="user_name" class="input-1" value="{$user.user_name|escape}" {if $role_info.role neq USER_ADMIN && $role_info.role neq USER_MERCHANDISER} disabled="disabled"{/if}
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">登陆密码:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="password" id="password" name="password" class="input-1" value=""
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">确认密码:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="password" id="confirm_password" name="confirm_password" class="input-1" value=""
								style="width: 162px;" />
						</td>
					</tr>
				</table>
				<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
					<tr>
						<th colspan="2" align="left" class="introduce_ti">&nbsp;&nbsp;&nbsp;&nbsp;基本资料</th>
					</tr>
					<!-- {if $smarty.get.act neq data_info} -->
					<tr>
						<td width="15%" align="right">跟单人:&nbsp;&nbsp;</td>
						<td align="left">
							<select name="freight_id">
								<!-- {foreach from=$freights item=fre} -->
									<option value="{$fre.user_id}" <!-- {if $fre.user_id==$user.freight_id} -->selected="selected"<!-- {/if} -->>{$fre.user_name}</option>
								<!-- {/foreach} -->
				            </select>
						</td>
					</tr>
					<!-- {/if} -->
					<tr>
						<td width="15%" align="right">客户名称:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="consumer_name" name="consumer_name" class="input-1" value="{$user.consumer_name|escape}"
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">用户类型:&nbsp;&nbsp;</td>
						<td align="left" width="85%" colspan="2">
							<input type="radio" id="merchant" name="user_type" class="input-1" value="1" {if $user.user_type eq 1}checked=true{/if} />批发商&nbsp;&nbsp;
							<input type="radio" id="retailer" name="user_type" class="input-1" value="2" {if $user.user_type eq 2}checked=true{/if} />零售商&nbsp;&nbsp;
							<input type="radio" id="designer" name="user_type" class="input-1" value="3" {if $user.user_type eq 3}checked=true{/if} />设计师
						</td>
					</tr>
					<!-- {if $smarty.get.act neq data_info} -->
					<tr>
						<td width="15%" align="right">VIP:&nbsp;&nbsp;</td>
						<td align="left" width="85%" colspan="2">
							<input type="radio" name="is_vip" class="input-1" value="1" {if $user.is_vip eq 1}checked=true{/if} />{$lang.yes}&nbsp;&nbsp;
							<input type="radio" name="is_vip" class="input-1" value="0" {if $user.is_vip eq 0}checked=true{/if} />{$lang.no}
						</td>
					</tr>
					<!-- {/if} -->
					<tr>
						<td width="15%" align="right">所属国家:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="country" name="country" class="input-1" value="<!-- {if $user.country} -->{$user.country|escape}<!-- {else} -->中国<!-- {/if} -->"
								style="width: 162px;"/>
						</td>
					</tr>
					<!-- {if $user.country=='中国' || !$user.country} -->
					<tr id="region_hidden">
						<td width="15%" align="right">所在区域:&nbsp;&nbsp;</td>
						<td align="left" id="regions">
							<input type="hidden" id="region_id" name="region_id" value="{$user.region_id}" class="mls_id" />
				            <input type="hidden" id="region_name" name="region_name" value="{$user.region_name}" class="mls_names" />
				            <!-- {if $user.user_id} -->
				            <span>{$user.region_name|escape}</span>
				            <input type="button" value="{$lang.edit}" class="edit_region" />
				            <select style="display:none">
				              <option>{$lang.select_pls}</option>
				              {html_options options=$regions}
				            </select>
				            <!-- {else} -->
				            <select>
				              <option>{$lang.select_pls}</option>
				              {html_options options=$regions}
				            </select>
				            <!-- {/if} -->
						</td>
					</tr>
					<!-- {/if} -->
					<tr>
						<td width="15%" align="right">详细地址:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="address" name="address" class="input-1" value="{$user.address|escape}"
								style="width: 500px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">固定电话:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="phone_tel" name="phone_tel" class="input-1" value="{$user.phone_tel|escape}"
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">手机号码:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="phone_mob" name="phone_mob" class="input-1" value="{$user.phone_mob|escape}"
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">邮箱:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="email" name="email" class="input-1" value="{$user.email|escape}"
								style="width: 162px;" />
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">QQ:&nbsp;&nbsp;</td>
						<td align="left">
							<input type="text" id="is_qq" name="is_qq" class="input-1" value="{$user.is_qq|escape}"
								style="width: 162px;" />
						</td>
					</tr>
				</table>
				
				<!-- {if $user.company_id} -->
				<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
					<tr>
						<th colspan="2" align="left" class="introduce_ti">&nbsp;&nbsp;&nbsp;&nbsp;公司资料</th>
					</tr>
					<tr>
						<td width="15%" align="right">中文名称:&nbsp;&nbsp;</td>
						<td align="left">
							<span>{$company.company_name|escape}</span>
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">英文名称:&nbsp;&nbsp;</td>
						<td align="left">
							<span>{$company.eng_company_name|escape}</span>
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">网址:&nbsp;&nbsp;</td>
						<td align="left">
							<span>{$company.company_site|escape}</span>
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">电话号码:&nbsp;&nbsp;</td>
						<td align="left" colspan="2">
							<span>{$company.tel|escape}</span>
						</td>
					</tr>
					<tr>
						<td width="15%" align="right">传真:&nbsp;&nbsp;</td>
						<td align="left" colspan="2">
							<span>{$company.fax|escape}</span>
						</td>
					</tr>
					<!-- {if $brand_list} -->
					<tr>
						<td width="15%" align="right">品牌:&nbsp;&nbsp;</td>
						<td align="left">
							<!-- {foreach from=$brand_list item=brand} -->
							<input type="checkbox" <!-- {if in_array($brand.brand_id,$brand_arr)} -->checked=true<!-- {/if} --> disabled="disabled"/>&nbsp;{$brand.brand_name|escape}&nbsp;&nbsp;
							<!-- {/foreach} -->
						</td>
					</tr>
					<!-- {/if} -->
				</table>
				<!-- {/if} -->
				<div style="text-align: center;padding-bottom: 8px">
					<input type="submit" value="提 交" class="btn-2" />
				</div>
			</form>
		</div>
	</div>
</body>
</html>